<template>
  <div>
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>用户管理</el-breadcrumb-item>
        <el-breadcrumb-item>注册用户管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="center" style="padding-top: 0px;">
      <div class="hander">注册用户管理</div>
      <div class="orderList">
        <div class="entirety">
          <div>
            <div class="search">
              <!--  账号状态搜索信息 -->
              <div class="demo-input-suffix">
                业主姓名

                <el-input
                  v-model="nickname"
                  placeholder="输入姓名"
                  clearable
                  style="width: 55%"
                ></el-input>
              </div>
              <div class="demo-input-suffix">
                手机号

                <el-input
                  v-model="phone"
                  clearable
                  style="width: 55%"
                  placeholder="输入手机号"
                ></el-input>
              </div>

              <div class="demo-input-suffix">
                管家姓名

                <el-input
                  v-model="extensionWorkerName"
                  placeholder="输入姓名"
                  clearable
                  style="width: 55%"
                ></el-input>
              </div>
              <div class="demo-input-suffix">
                认证终端

                <el-select
                  style="width: 55%"
                  clearable
                  v-model="channelNo"
                  placeholder="请选择"
                >
                  <el-option label="IOS" value="IOS"></el-option>
                  <el-option label="小程序" value="小程序"></el-option>
                  <el-option label="Android" value="Android"></el-option>
                </el-select>
              </div>
            </div>
            <div class="top">
              <div class="demo-input-suffix">
                注册时间
                <el-date-picker
                  v-model="TimeLIst"
                  type="datetimerange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  size="mini"
                  align="right"
                  prefix-icon="el-icon-date"
                  clear-icon="el-icon-close"
                  :editable="false"
                >
                </el-date-picker>
              </div>
              <!--  账号状态搜索信息 -->
              <div class="demo-input-suffix" style="margin-right:35px">
                <el-button
                  style="background-color:#fd804c;color: #fff;"
                  @click.native.prevent="isSelect"
                  >查询</el-button
                >
                <el-button type="warning" @click.native.prevent="isEmpty"
                  >清空</el-button
                >
              </div>
            </div>
          </div>
        </div>
        <!-- nav展示 -->
        <div class="nav">
          <div class="money" style="width: 24%;cursor:pointer">
            <div class="moneyLeft">
              <div class="one">
                {{ registerTotalNumber }}
              </div>
              <el-tooltip
                class="item hand"
                effect="dark"
                content="总注册用户"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">总注册用户</div>
                </div>
              </el-tooltip>
            </div>
          </div>
          <!-- 总认证用户 -->
          <div class="money" style="width: 24%">
            <div class="moneyLeft">
              <div class="one">
                {{ authTotalNumber }}
              </div>
              <el-tooltip
                class="item"
                effect="dark"
                content="总认证用户"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">总认证用户</div>
                </div>
              </el-tooltip>
            </div>
          </div>
          <!-- 今日注册用户数 -->
          <div class="money" style="width: 24%">
            <div class="moneyLeft">
              <div class="one">
                {{ todayRegisterMember }}
              </div>

              <el-tooltip
                class="item"
                effect="dark"
                content="今日注册用户数"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">今日注册用户数</div>
                </div>
              </el-tooltip>
            </div>
          </div>
          <!-- 今日认证用户数 -->
          <div class="money" style="width: 24%">
            <div class="moneyLeft">
              <div class="one">
                {{ todayAuthMember }}
              </div>

              <el-tooltip
                class="item"
                effect="dark"
                content="今日认证用户数"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">今日认证用户数</div>
                </div>
              </el-tooltip>
            </div>
          </div>
        </div>
        <!--  员工列表栏位-->
        <div
          class="entirety"
          v-loading="isLoading"
          element-loading-text="数据加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-custom-class="loading_color"
        >
          <div class="footer">
            <el-table :data="tableData" style="width: 100%">
              <el-table-column prop="avatarAddress" label="头像">
                <template slot-scope="scope">
                  <el-image
                    style="width: 70px; height: 30px"
                    :src="scope.row.avatarAddress"
                    :preview-src-list="[scope.row.avatarAddress]"
                    :fit="'contain'"
                  ></el-image>
                </template>
              </el-table-column>
              <el-table-column prop="memberNo" label="用户ID">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.memberNo }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="nickname" label="昵称">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.nickname }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="userName" label="姓名">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.userName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="phone" label="手机号">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.phone }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="channelNo" label="注册终端">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.channelNo }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="createTime" label="注册时间">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.createTime }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="authStatus" label="是否认证房屋">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.authStatus === "2" ? "是" : "否" }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="authTime" label="认证时间">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.authTime }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="extensionWorkerName" label="管家姓名">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.extensionWorkerName }}
                  </div>
                </template>
              </el-table-column>

              <el-table-column fixed="right" label="操作">
                <template slot-scope="scope">
                  <el-button
                    v-if="scope.row.authStatus !== '2'"
                    @click.native.prevent="isHouseDetail(scope.row.memberNo)"
                    type="text"
                    size="small"
                    :disabled="scope.row.authStatus !== '2'"
                  >
                    房屋详情
                  </el-button>
                  <el-button
                    style="color: #fc9e76;"
                    v-else
                    @click.native.prevent="isHouseDetail(scope.row.memberNo)"
                    type="text"
                    size="small"
                  >
                    房屋详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="block">
              <div class="left"></div>
              <div class="right">
                <el-pagination
                  layout="total, sizes, prev, pager, next, jumper"
                  class="page"
                  @size-change="sizeChangeHandle"
                  @current-change="currentChangeHandle"
                  :current-page="pageIndex"
                  :page-size="pageSize"
                  :total="total"
                >
                </el-pagination>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";

export default {
  data() {
    return {
      nickname: "",
      phone: "",
      channelNo: "",
      TimeLIst: [],
      isLoading: false,

      extensionWorkerName: "",
      extensionWorkerNo: "",
      pageIndex: 1,
      pageSize: 20,
      total: 0,
      tableData: [],
      id: "",
      authTotalNumber: 0,
      registerTotalNumber: 0,
      todayAuthMember: 0,
      todayRegisterMember: 0,
      userSearch: 0,
      regionsList: [],
      business: []
    };
  },
  activated() {
    if (!!this.$route.params.extensionWorkerNo) {
      this.extensionWorkerNo = this.$route.params.extensionWorkerNo;
    } else {
      this.isEmpty();
    }
    this.DetailByPage();
  },

  methods: {
    isSelect() {
      (this.pageIndex = 1), (this.pageSize = 20), this.DetailByPage();
    },
    //房屋详情
    isHouseDetail(memberNo) {
      this.$router.push({
        name: "houseDetail",
        params: {
          memberNo
        }
      });
    },
    isEmpty() {
      (this.nickname = ""),
        (this.phone = ""),
        (this.channelNo = ""),
        (this.extensionWorkerName = ""),
        (this.extensionWorkerNo = ""),
        (this.pageIndex = 1),
        (this.pageSize = 20),
        this.DetailByPage();
    },
    //分页获取优惠券模板列表接口调用
    DetailByPage() {
      this.isLoading = true;

      this.$http({
        url: `/memberadmin/mgr/register/fetchMemberRegisterMessage`,
        method: "GET",
        params: {
          authType: "",
          nickname: this.nickname,
          phone: this.phone,
          channelNo: this.channelNo,
          extensionWorkerName: this.extensionWorkerName,
          extensionWorkerNo: this.extensionWorkerNo,
          registerCreateTime: this.TimeLIst[0]
            ? moment(this.TimeLIst[0]).format("YYYY-MM-DD HH:mm:ss")
            : "",
          registerEndTime: this.TimeLIst[1]
            ? moment(this.TimeLIst[1]).format("YYYY-MM-DD HH:mm:ss")
            : "",
          size: this.pageSize,
          page: this.pageIndex
        }
      })
        .then(res => {
          this.isLoading = false;
          this.tableData = res.memberRegisterResponseList.list;
          (this.authTotalNumber = res.authTotalNumber),
            (this.registerTotalNumber = res.registerTotalNumber),
            (this.todayAuthMember = res.todayAuthMember),
            (this.todayRegisterMember = res.todayRegisterMember),
            (this.total = parseInt(res.memberRegisterResponseList.total));
        })
        .catch(_ => {
          this.isLoading = false;
        });
    },

    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;

      this.DetailByPage();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;

      this.DetailByPage();
    }
  }
};
</script>
<style scoped lang="scss">
.block {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 10px 0 10px;
}
.left {
  font-size: 15px;
}
.hander {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.balance-searchMoney {
  display: flex;
  align-items: center;
}
.input {
  flex: 1;
  margin-left: 5px;
}
.nav {
  width: 102%;
  margin-top: 12px;
  margin-left: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.money {
  // height: 100px;
  background-color: #fff;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  border-radius: 6px;
  // margin-bottom: 24px !important;
}
.money div {
  color: #333;
  box-sizing: border-box;
}
.one {
  font-size: 20px;
  font-weight: 500;
  color: #000;
}
.money .two {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}
.moneyRight {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}
.moneyImg {
  width: 72px;
  height: 72px;
}
.f16 {
  font-size: 16px;
}
.moneyLeft {
  flex: 1;
  background: #f2f2f2;
  text-align: center;
  padding-top: 10px;
  padding-bottom: 10px;
}
.news {
  margin-left: 60%;
}
.orderList {
  background-color: #ebeef1;
  padding-right: 40px;
  padding-top: 1px;
  padding-bottom: 1px;
  display: block;
  font-size: 16px;
  border-radius: 20px;
  list-style-type: none;
}
.entirety {
  width: 100%;
  margin: 10px;
  height: 100%;
  padding: 10px;
  background-color: #fff;
  border-radius: 10px;
  display: flex;
  padding-left: 10px;
  .basic {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2%;
    margin-bottom: 1%;
    margin-left: 1%;
  }
}
.footer {
  width: 100%;
  display: flex;
  overflow: hidden;
  flex-direction: column;
}
.page {
  margin-top: 15px;
}
.search {
  margin-bottom: 15px;
}
.top {
  display: flex;
  justify-content: space-between;
}
/deep/ .el-range-editor--mini {
  height: 35px;
  width: 350px;
  text-align: center;
}
/deep/ .el-range-separator {
  line-height: 25px;
}
.overall {
  width: 100%;
  height: auto;
  display: flex;

  justify-content: space-between;
  margin-top: 3%;
  .left {
    width: 20%;
    height: auto;
  }
  .right {
    width: 80%;
    height: auto;
  }
}
.demo-input-suffix {
  margin-left: 2%;
}
.select {
  width: 65%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.topImg {
  margin-right: 20px;
}

/deep/ .el-loading-spinner i {
  color: #fc9e76;
}
/deep/ .el-loading-spinner .el-loading-text {
  color: #fc9e76;
  margin: 3px 0;
  font-size: 14px;
}
/deep/ .itemClass .el-form-item__content {
  width: 350px;
}
.userSearch {
  display: flex;
  /deep/ .el-input__inner {
    box-sizing: border-box;
    height: 40px;
    border-radius: 0;
    width: 132px;
    border: 1px solid #dcdfe6;
  }
  /deep/ .el-icon-arrow-up:before {
    position: relative;
    top: -4px;
  }
  /deep/ .el-button {
    height: 40px;
    border-radius: 0;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-right: none;
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}
.selects {
  width: 55%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}
/deep/ .but {
  background: #fd7097;
  color: #fff;
  margin-bottom: 1%;
}
</style>
